package com.dyg.service.Impl;

import java.util.List;
import com.dyg.model.Resource;
import com.dyg.dao.ResourceMapper;
import com.dyg.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ResourceServiceImpl implements ResourceService {

	@Autowired
	private ResourceMapper resourceMapper;

	@Override
	public Resource insertResource(Resource resource){
		this.resourceMapper.insertResource(resource);
		return resource;
	}

	@Override
	public void deleteResourceById(String resourceId)	{
		this.resourceMapper.deleteResourceById(resourceId);
	}

	@Override
	public Resource updateResource(Resource resource)	{
		this.resourceMapper.updateResource(resource);
		
		return resource;
	}

	@Override
	public Resource findResourceById(String resourceId)	{
		return this.resourceMapper.findResourceById(resourceId);
	}

	@Override
	public List<Resource> findResourceList()	{
		return this.resourceMapper.findResourceList();
	}

	
	/**
	 * 查询指定用户id所拥有的权限
	 */
	@Override
	public List<Resource> listAllResource(int userId) {
		
		return resourceMapper.listAllResource(userId);
	}

	/**
	 * 查询角色拥有的资源集合
	 * @param id
	 * @return
	 */
	@Override
	public List<Resource> listRoleResource(Integer id) {
		
		return resourceMapper.listRoleResource(id);
	}
}
